<script lang="ts">
import { defineComponent } from "vue";

import FormButton from "@/components/form/button.vue";

export default defineComponent({
  components: { FormButton },
  props: {
    title: { type: String, default: "合计" },
    price: String,
    btnText: { type: String, default: "去支付" },
    detailVisible: { type: Boolean, default: true },
  },
  emits: {
    "btn-click": (type: string) => typeof type === "string",
  },
  setup(props, ctx) {
    const btnClick = (type: string) => {
      ctx.emit("btn-click", type);
    };

    return { btnClick };
  },
});
</script>

<template>
  <view class="settle-bar">
    <view class="settle-bar-label">{{ title }}</view>

    <view class="settle-bar-price">
      <text class="settle-bar-price2">￥</text>{{ price }}
    </view>

    <view
      class="settle-bar-detail"
      v-if="detailVisible"
      @click="btnClick('detail')"
    >
      明细
    </view>

    <view class="settle-bar-btn" @click="btnClick('btn')">
      <FormButton>{{ btnText }}</FormButton>
    </view>
  </view>
</template>

<style lang="scss">
.settle-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-right: 30rpx;

  .settle-bar-label {
    font-size: 28rpx;
    color: #2d2d2d;
    line-height: 56rpx;
  }

  .settle-bar-price {
    margin-bottom: 10rpx;
    font-size: 48rpx;
    color: #fa6400;
    line-height: 66rpx;
    font-weight: bold;
  }

  .settle-bar-price2 {
    font-size: 32rpx;
    line-height: 44rpx;
  }

  .settle-bar-detail {
    margin-left: 20rpx;
    font-size: 24rpx;
    color: #999999;
    line-height: 42rpx;
    text-decoration: underline;
  }

  .settle-bar-btn {
    width: 334rpx;
    margin-left: 30rpx;
  }
}
</style>